package com.songlanyun.modules.userbankscard.controller.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.annotation.RepeatSubmit;
import com.songlanyun.common.enums.MemberConstant;
import com.songlanyun.common.utils.R;
import com.songlanyun.common.validator.ValidatorUtils;
import com.songlanyun.modules.userbankcard.entity.BankCardIconEntity;
import com.songlanyun.modules.userbankcard.entity.UserBankCardEntity;
import com.songlanyun.modules.userbankcard.model.dto.UserBankCardDTO;
import com.songlanyun.modules.userbankscard.dao.UserBanksCardDao;
import com.songlanyun.modules.userbankscard.entity.UserBanksCardEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/member/bankcards")
public class UserBanksCardApiController {

    @Autowired
    private UserBanksCardDao userBanksCardDao;

    /**
     * 列表
     */
    @RequestMapping("/select")
    public R select(@RequestParam Map<String, Object> params) {
        List<UserBanksCardEntity> bankCardIconEntityList = userBanksCardDao.selectList(
                new LambdaQueryWrapper<UserBanksCardEntity>()
                        .eq(UserBanksCardEntity::getUserId, params.get("userId")));
        return R.ok().put("list", bankCardIconEntityList);
    }

    /**
     * 会员保存/修改银行卡信息
     */
    @RepeatSubmit(value = "2")
    @PostMapping("/save")
    //@RequiresPermissions("userbankcard:userbankcard:save")
    public R save(@RequestBody UserBankCardDTO dto) {
//        ValidatorUtils.validateEntity(dto);
//        userBanksCardDao.saveBankCard(dto, MemberConstant.UserType.MEMBER, getUserId(true));
        return R.ok();
    }

}
